#include <iostream>
#include<vector>
#include<map>
using namespace std;

int main() {
    int n;
    cin >> n;
    map<char, int>m;
    vector<char>p = { 'y','o','u' };
    vector<int>sum(n);
    int x;
    for (int i = 0; i < n; i++)
    {
        sum[i] = 0;
        m.clear();
        for (int j = 0; j < 3; j++)
        {
            cin >> x;
            m[p[j]] = x;
        }
        int a = min(m['y'], m['o']);
        int b = min(a, m['u']);
        sum[i] += b * 2;
        if (m['o'] > b && m['o'] >= 2)
        {
            sum[i] += ((m['o'] - b) - 1);
        }


    }
    for (int i = 0; i < n; i++)
    {
        cout << sum[i] << endl;
    }
    return 0;
}